#include <map>
#include <list>
#include <vector>
#include "SoundSystem.h"
#include "CoreSystem.h"
#include "XMLDoc.h"


#pragma warning( disable : 4100 )


bool SoundSystem::Initialize( HWND hwnd, bool for_tool )
{
	m_core = Audio::CoreSystem::Inst();
	return m_core->Initialize(hwnd, for_tool);
}

bool SoundSystem::Destroy()
{
	m_core->Destroy();
	m_core = NULL;
	return true;
}

void SoundSystem::Update(float delta)
{
	m_core->Update(delta);
}

bool SoundSystem::LoadSoundXML( const char* file, XMLFileHandle& handle )
{
	assert(m_core);
	handle = m_core->LoadSoundXML(file);
	return handle ? true : false;
}

bool SoundSystem::UnloadSoundXML( XMLFileHandle handle)
{
	assert(m_core);
	return m_core->UnloadSoundXML(handle);
}

bool SoundSystem::IsXMLLoaded( const char* file )
{
	assert(m_core);
	return m_core->GetXMLHandle(file) ? true : false;
}

bool SoundSystem::GetVarHandle( const char* varName, VariableHandle& handle, XMLFileHandle xmlFile )
///////////////////////////////////////////////////////////////////////////////
// Description: Finds the variable and returns a handle.  If the variable
//				doesn't exist, returns false;
//
// Recent Changes:
// -jkern	 4/04/2007 : Added an assert for m_core
// -brasmuss 3/30/2007 : Created
///////////////////////////////////////////////////////////////////////////////
{
	assert( m_core );
	handle = m_core->GetVariableHandle(varName,xmlFile);
	return ( handle > 0 );
}

bool SoundSystem::UpdateVariable( VariableHandle& handle, float value, XMLFileHandle xmlFile )
{
	assert( m_core );
	return m_core->SetVariableValue(handle,value,xmlFile);
}

bool SoundSystem::TriggerEvent( const char* eventName, XMLFileHandle xmlFile )
{
	assert( m_core );
	return m_core->TriggerEvent(eventName,xmlFile);
}

bool SoundSystem::StopEvents()
{
	return m_core->StopEvents();
}



///////////////////////////
// DIRCECT ACCESS METHODS
///////////////////////////
bool SoundSystem::LoadSoundFile( const WCHAR* file, FileHandle& handle )
{
	assert(m_core);
	handle = m_core->LoadSoundFile(file);
	return ( handle > 0 );
}
bool SoundSystem::LoadStreamFile( const WCHAR* file, FileHandle& handle  )
{
	assert(m_core);
	handle = m_core->LoadStreamFile(file);
	return ( handle > 0 );
}

ChannelHandle	SoundSystem::PlayFile( const WCHAR* file, bool looping, float volume )
{
	assert(m_core);
	return m_core->PlayFile(file);
}

ChannelHandle	SoundSystem::PlayFile( FileHandle fileID, bool looping, float volume )
{
	assert(m_core);
	return m_core->PlayFile(fileID, looping);
}

void SoundSystem::UnloadSoundFile( FileHandle fileID )
{
	assert(m_core);
	m_core->UnloadSoundFile(fileID);
}

void SoundSystem::PlaySound(const ChannelHandle& soundID )
{
	assert(m_core);
	m_core->PlaySound(soundID);
}

void SoundSystem::SetVolume(const ChannelHandle& soundID, float volume )
{
	assert(m_core);
	m_core->SetVolume(soundID,volume);
}

void SoundSystem::StopSound(const ChannelHandle& soundID )
{
	assert(m_core);
	m_core->StopSound(soundID);
}


